#ifndef _TALK_H
#define _TALK_H

#include "base.h"
////////////////////////////////////////////////////////////////////
/// 华丽的分割线
////////////////////////////////////////////////////////////////////

using namespace type;

class Talking
{
	private:
		std::map<uint8, std::string> talkList;
		std::map<uint8, std::vector<uint8> > talkLink;
		static Talking *instance;		/// 唯一实例
		Talking()
		{
			///////////////////////////////////
			/// 1: 2, 3
			/// 2: 4
			/// 3: 6
			/// 4: 5
			/// 6: 7
			/// 7: 8, 9
			/// 8: 10
			/// 9: 10
			///////////////////////////////////
			talkList.insert(std::make_pair(1, "I love You!"));
			talkList.insert(std::make_pair(2, "Me too!"));
			talkList.insert(std::make_pair(3, "I don't love you!"));
			talkList.insert(std::make_pair(4, "oh, you love Me, baby?"));
			talkList.insert(std::make_pair(5, "Sure!"));
			talkList.insert(std::make_pair(6, "You don't love Me?"));
			talkList.insert(std::make_pair(7, "Yes, I don't love You!"));
			talkList.insert(std::make_pair(8, "So sad!"));
			talkList.insert(std::make_pair(9, "Ok, I don't love You any more!"));
			talkList.insert(std::make_pair(10, "SB"));
			std::vector<uint8> tmp;
			tmp.push_back(2);
			tmp.push_back(3);
			talkLink.insert(std::make_pair(1, tmp));
			tmp.clear();
			tmp.push_back(4);
			talkLink.insert(std::make_pair(2, tmp));
			tmp.clear();
			tmp.push_back(6);
			talkLink.insert(std::make_pair(3, tmp));
			tmp.clear();
			tmp.push_back(5);
			talkLink.insert(std::make_pair(4, tmp));
			tmp.clear();
			tmp.push_back(7);
			talkLink.insert(std::make_pair(6, tmp));
			tmp.clear();
			tmp.push_back(8);
			tmp.push_back(9);
			talkLink.insert(std::make_pair(7, tmp));
			tmp.clear();
			tmp.push_back(10);
			talkLink.insert(std::make_pair(8, tmp));
			tmp.clear();
			tmp.push_back(10);
			talkLink.insert(std::make_pair(9, tmp));
		}
		~Talking() { }
	public:
		static Talking* getInstance()
		{
			if(instance == NULL)
			{
				instance = new Talking;
				if(instance == NULL) return NULL;
				else return instance;
			}
			return instance;
		}
		void delInstance()
		{
			delete instance;
		}

		uint8 getTalkNum()
		{
			return talkList.size();
		}
		bool pushTalk(uint8 id, const std::string& talk)
		{
			if(talk != "" && talkList.find(id) == talkList.end())
			{
				talkList.insert(std::make_pair(id, talk));
				return true;
			}
			else return false;
		}
		bool getTalkByID(uint8 id, std::string &talk)
		{
			if(this->talkList.find(id) != this->talkList.end())
			{
				talk = this->talkList[id];
				return true;
			}
			else return false;
		}
		uint8 getNextTalkByID(uint8 id)
		{
			if(this->talkLink.find(id) != this->talkLink.end())
			{
				int size = this->talkLink[id].size() - 1;
				uint8 idx = (uint8)randBetween(0, size);
				if(this->talkLink[id].size() > idx)
					return this->talkLink[id][idx];
			}
			return 0;
		}
		uint8 getNextTalkByRelationAndEmotion(uint8 id, uint8 Relation, uint8 emotion)
		{
			return 0;
		}
};

////////////////////////////////////////////////////////////////////
/// 华丽的分割线
////////////////////////////////////////////////////////////////////

#endif

